<template>
  <div class="myteam">
    <h5>我的团队预估收益 (昨天之前)</h5>
    <x-table :cell-bordered="false">
      <thead>
      <tr>
        <th></th>
        <th>邀请收益 (元)<span @click.stop="invitebadge"><badge text="?"></badge></span></th>
        <th>团队收益 (元)<span @click.prevent="teambadge"><badge text="?"></badge></span></th>
      </tr>
      </thead>
      <tbody>
      <tr v-for="(item, index) in teamlist" :key="index">
        <td>{{item.monthName}}</td>
        <td>￥{{item.inviteIncome}}元</td>
        <td>￥{{item.teamIncome}}元</td>
      </tr>
      </tbody>
    </x-table>
</div>
</template>
<script>
import api from '../../api'
import { XTable, Badge } from 'vux'
import utils from '../../utils'
export default {
  data () {
    return {
      teamlist: [],
      tokenval: ''
    }
  },
  components: {
    XTable,
    Badge
  },
  created () {
    var timeStamp = String(Number(new Date()))
    this.tokenval = utils.AuthToken(timeStamp, this.$store.state.userkey)
    var params = {
      Tokenuser: this.tokenval,
      userid: this.$store.state.userID,
      timestamp: timeStamp
    }
    api.bymonth(params).then(res => {
      console.log(res)
      this.teamlist = res.data.list
    })
  },
  methods: {
    invitebadge () {
      this.$vux.alert.show({
        title: '邀请收益',
        content: '您获取的下级团队的收益'
      })
    },
    teambadge () {
      this.$vux.alert.show({
        title: '团队收益',
        content: '下级推广员累积收益'
      })
    }
  }
}
</script>
